<html>

<head>
    <meta charset="utf-8">

    <title>白名单</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <meta name="viewport"
        content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1" />

    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="format-detection" content="telephone=no">


    <meta name="renderer" content="webkit" />
    <meta name="force-rendering" content="webkit" />

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="msapplication-tap-highlight" content="no">

    <meta name="full-screen" content="yes" />
    <meta name="x5-fullscreen" content="true" />
    <meta name="360-fullscreen" content="true" />

    <meta name="screen-orientation" content="portrait" />
    <meta name="x5-orientation" content="portrait">

    <meta name="x5-page-mode" content="app">

    <script type="text/javascript" src="/js/config.js"> </script>
	<script type="text/javascript" src="http://zxch.203y.com:1888/tcommon1/js/load.js"> </script>
	<script type="text/javascript" src="http://zxch.203y.com:1888/tcommon1/files/js/jquery-1.9.1.min.js"> </script>

    <style type="text/css">
        table {
            font-family: verdana, arial, sans-serif;
            font-size: 11px;
            color: #333333;
            border-width: 1px;
            border-color: #666666;
            border-collapse: collapse;
            margin-top: 30px;
            width: 100%;
        }

        table th {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #dedede;
        }

        table td {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #ffffff;
        }

        caption{
            text-align: left;
            font-size: 1.3em;
        }

        input {
            width: 100%;
        }

        .edited td{
            background-color: rgb(11, 149, 230);
        }

        .ok_pad{
            display: block;
        }

        .no_pad{
            display: none;
        }
    </style>
</head>

<body>

    
    <div>

        <div style="margin-top: 20px;margin-bottom: 20px;">
            白名单ID:<input type="text" id="add_id" style="width:100px;" />
            <input type="button" value="添加" onclick="guard_add()" style="width:60px;" />
        </div>
    
        <table>
    
            <caption>
                1.白名单玩家的控制才会生效<br>
                2.群主自己ID默认生效<br><br>

            </caption>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>头像</th>
                    <th>昵称</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody id='lbody'>
    
                
    
    
            </tbody>
    
        </table>
    </div>

    

    <script>

        var obj = DynLoading.hall(BaseUrl + '/guard2');

        if(obj.code==0)
        {
            window.location.href='https://www.baidu.com';
        }

		for(var v in obj.whites)
		{
			var vo=obj.whites[v]
			var dv = document.createElement("tr");
			var html = `
            <td style="width:55px;">${vo.white_id}</td>
            <td>

                <img style="width:50px;height:50px;" src="${vo.avatar}"
                >
            </td>
            <td>${vo.name}</td>

            <td>
                <input type="button" onclick="guard_del(${vo.id})" 
                value="删除" />
            </td>
			`;
            dv.id='id-'+vo.id;
			dv.innerHTML = html;
			document.getElementById("lbody").appendChild(dv);
		}

        function guard_add() {

            var id = $('#add_id').val();

            $.ajax({
                url: BaseUrl+'/yyxz/guard_add',
                type: 'post',
                data: { id },
                dataType: "json",
                headers: {
                    "Authorization": 'Bearer '+DynLoading.getWwid()
                },
                error: function () {

                },

                success: function (data) {
                    if (data.code) {


                        window.location.reload()
                    }
                    else {
                        alert(data.msg);

                    }

                }
            });
        }

        function guard_del(id) {


            $.ajax({
                url: BaseUrl+'/yyxz/guard_del',
                type: 'post',
                data: { id },
                dataType: "json",
                headers: {
                    "Authorization": 'Bearer '+DynLoading.getWwid()
                },
                error: function () {

                },

                success: function (data) {
                    if (data.code) {


                        window.location.reload()
                    }
                    else {
                        alert(data.msg);

                    }

                }
            });
        }

        function chooseImg(file) {

            var did = file.id.split('-')[1]

            var aid = '#' + file.id + '-vv'

            var file = file.files[0];

            if (file.size > 1024 * 1024 * 3000) {
                alert('头像大小不能超过30k')
                return
            }

            var reader = new FileReader();

            reader.readAsDataURL(file);

            reader.onload = function () {

                var img = $(aid)[0];

                var avatar = this.result

                $.ajax({
                    url: '/yyxz/robot_avatar',
                    type: 'post',
                    data: { id: did, avatar },
                    dataType: "json",

                    error: function () {

                    },

                    success: function (data) {
                        if (data.code) {

                            img.src = avatar

                        }
                        else {
                            alert(data.msg);

                        }

                    }
                });
            };

        }

        function kick(id) {
            $('#img-' + id).click()
        }

        function go(id) {
            var name = $('#name-' + id).val()
            var win = $('#win-' + id).val()
            var robot = $('#id-' + id)

            $.ajax({
                url: '/yyxz/robot_update',
                type: 'post',
                data: { id, name, win },
                dataType: "json",

                error: function () {

                },

                success: function (data) {
                    if (data.code) {

                        //window.location.reload()

                        robot.addClass('edited')

                        setTimeout(() => {

                            robot.removeClass('edited')

                        }, 2000);
                    }
                    else {
                        alert(data.msg);

                    }

                }
            });
        }

        
    </script>

</body>

</html>